package action.startup;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import component.RunCmdComponent;
import constants.Constants;
import utils.GameUtils;

/**
 * @Auther syc.
 * @Date 2016/11/9 11:27.
 */
public class StartAllServerAction extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        Application application = ApplicationManager.getApplication();
        RunCmdComponent component = application.getComponent(RunCmdComponent.class);

        String path = GameUtils.getPropertyValue(anActionEvent, Constants.PROJECT_PATH_PRO_NAME);

        //Start the db server
        component.commandsBatProccess(anActionEvent, path, "startDBServer" ,Constants.DB_STARTUP_BAT);

        //Start the world server
        component.commandsBatProccess(anActionEvent, path, "startWorldServer",Constants.WORLD_STARTUP_BAT);
    }
}
